
#include <iostream>
#include <vector>
#include <memory>

using namespace std;


class Target
{
public:
    virtual double getValue(int index){
        return static_cast<double>(index);
    }
    virtual ~Target(){};

};

class Adaptee
{
public:
    int getValue(int index){
        return static_cast<int>(index + 10);
    }
};


class Adapter : public Target
{
private:
    Adaptee* m_adaptee;
 
public:
    double getValue(int index){
        return m_adaptee->getValue(index);
    }

    Adapter(){
        m_adaptee = new Adaptee();
    }
    Adapter(Adaptee* adaptee){
        m_adaptee = adaptee;
    }
    ~Adapter(){
        if(m_adaptee){
            delete m_adaptee;
        }
    }
};



int main(int argc, char const *argv[])
{
    int test_value = 100;

    unique_ptr<Target> target(new Target());
    cout << "The output value:" << target->getValue(test_value) << endl;


    cout << "\n\nTest for adapter"<<endl;

    target.reset(new Adapter());
    cout <<"The output value:" << target->getValue(test_value) << endl;

    return 0;
}
